import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '名称',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '创建日期',
    align:"center",
    sorter: true,
     width:150,
    dataIndex: 'createTime'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '名称',
    field: 'name',
    component: 'JInput'
    }
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
         return [
                { required: true, message: '请输入规则名!'},
         ];
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

//关联设备查询数据
export const channelDevSearchFormSchema: FormSchema[] = [
  {
      label: "设备名称",
      field: 'deviceName',
      component: 'Input',
      colProps: {span: 6},
  },
  {
      label: "设备类型",
      field: 'deviceType',
      component: 'Input',
      colProps: {span: 6},
      defaultValue:1,
      show:false
  }
];
//查询一体机设备
export const  devSearchFormSchema: FormSchema[] = [
  {
      label: "设备名称",
      field: 'deviceName',
      component: 'Input',
      colProps: {span: 6},
  },
  {
      label: "设备类型",
      field: 'deviceType',
      component: 'Input',
      colProps: {span: 6},
      defaultValue:1,
      show:false
  },
  {
    label: "门id为null",
    field: 'doorIdNull',
    component: 'Input',
    colProps: {span: 6},
    defaultValue:1,
    show:false
}
];

/** 通道关联设备列表
 */
export const channelDevColumns: BasicColumn[] = [
  {
   title: '设备名称',
   align:"center",
   dataIndex: 'deviceName',
   width:150
  },
  {
   title: '设备类型',
   align:"center",
    width:150,
   dataIndex: 'deviceType',
   customRender: ({ text }) => {
     return render.renderDict(text, 'deviceType');
   },
  },
  {
   title: '在线状态',
   align:"center",
   dataIndex: 'isOnline',
    width:80,
   customRender: ({ text }) => {
     return !text?"":(text=='0'?'离线':'在线');
   }
   }
];

export const devColumns:BasicColumn[] = [
  {
   title: '设备编码',
   align:"center",
   dataIndex: 'deviceCode'
  },
  {
   title: '设备名称',
   align:"center",
   dataIndex: 'deviceName'
  },
  {
   title: '设备标识码',
   align:"center",
   dataIndex: 'deviceSn'
  },
  {
   title: '设备类型',
   align:"center",
   dataIndex: 'deviceType',
   customRender: ({ text }) => {
     return render.renderDict(text, 'deviceType');
   },
  },
  {
   title: '设备地址',
   align:"center",
   dataIndex: 'deviceIp'
  },
];


// 高级查询数据
export const superQuerySchema = {
  name: {title: '名称',order: 0,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
